﻿using System;
using System.Windows;
using System.Windows.Browser;
using System.Windows.Controls;
using SoftSource.Timecard.Entry.Resources;

namespace SoftSource.Timecard.Entry
{
    public sealed partial class Root : UserControl
    {
        public Root()
        {
            InitializeComponent();
        }

        new public UIElement Content
        {
            get { return (UIElement)GetValue(ContentProperty); }
            set { SetValue(ContentProperty, value); }
        }

        // Using a DependencyProperty as the backing store for Content.  This enables animation, styling, binding, etc...
        new public static readonly DependencyProperty ContentProperty =
            DependencyProperty.Register("Content", typeof(UIElement), typeof(Root), new PropertyMetadata(null, (sender, e) =>
            {
                Root root = sender as Root;
                if (root != null)
                    root.MasterPage.MainContent = (UIElement)e.NewValue;
            }));

        private void Logoff_Click(object sender, RoutedEventArgs e)
        {
            App.Current.Logout();
        }

        private void Login_Click(object sender, RoutedEventArgs e)
        {
            App.Current.LoadUser();
        }

        private void AdministrationLink_Click(object sender, RoutedEventArgs e)
        {
            HtmlPage.Window.Navigate(new Uri(ApplicationStrings.AdministrationURI, UriKind.RelativeOrAbsolute));
        }
    }
}
